from flask import Flask
from blueprints.login import bp as login_register
from blueprints.cal import bp as cal
from datetime import timedelta
from blueprints.userinfo import bp as userinfo
from flask_jwt_extended import create_access_token, jwt_required, get_jwt_identity,JWTManager,create_refresh_token
from flask_jwt_extended import JWTManager

from flask_cors import CORS
app = Flask(__name__)

# r'/*' 是通配符，让本服务器所有的 URL 都允许跨域请求
CORS(app, resources=r'/*')

app.secret_key = 'ChangeMe!'
# app.config['JWT_SECRET_KEY'] = 'my_secret_key'
app.config['JWT_BLACKLIST_ENABLED'] = True
app.config['JWT_BLACKLIST_TOKEN_CHECKS'] = ['access']
# 设置普通JWT过期时间
app.config["JWT_ACCESS_TOKEN_EXPIRES"] = timedelta(days=1)
# 设置刷新JWT过期时间
app.config["JWT_REFRESH_TOKEN_EXPIRES"] = timedelta(days=30)

app.register_blueprint(login_register)
app.register_blueprint(userinfo)
app.register_blueprint(cal)
# 初始化jwt
jwt = JWTManager(app)
jwt.init_app(app)

@app.route('/')
def hello_world():  # put application's code here
    return 'Hello World!'


if __name__ == '__main__':
    app.run()
